package com.wc.fortnight_blue_bridge.Q241005.D_古墓机关;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/5 21:59
 * @description https://www.lanqiao.cn/problems/19863/learning/?contest_id=210
 */
public class Main {

    /**
     * 隔板法<p>
     * 从n个花瓶里面选m朵花, 每个花瓶中有无数朵花<p>
     * x[1] + x[2] + ... + x[n] = m, x[i] >= 0<p>
     * x[1] + 1 + x[2] + 1 + ... + x[n] + 1 = m + n<p>
     * y[1] + y[2] + ... + y[n] = m + n, y[i] >= 1<p>
     * 可以使用隔板法计算出方案数, 一共有 m + n - 1个空隙, 插入 n - 1块板子, 来形成 n 个瓶子中的花<p>
     * ans = C(n + m - 1, n - 1), C(n, m) 代表从 n 中 选出 m 个的组合数<p>
     * C(n, m) = n! / (m! * (n - m)!)<p>
     * 思路：<p>
     * 题目意思可以等价于从 m 个花瓶中选出 n 个数, x[i]表示从第i个花瓶中选择x[i]个数<p>
     * x[1] + x[2] + ... + x[m] = n, x[i] >= 0<p>
     * 根据上面的隔板法的公式的出<p>
     * ans = C(n + m - 1, m - 1)
     **/

    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010, P = 998244353;
    // inv[i]表示 1 * 2 * 3 ... * i 的逆元, up[i] 表示 1 * 2 * 3 ... * i
    static long[] inv = new long[N], up = new long[N];
    static int n, m;

    public static void main(String[] args) {
        up[0] = 1;
        inv[0] = 1;
        for (int i = 1; i < N; i++) {
            up[i] = up[i - 1] * i % P;
            inv[i] = qmi(up[i], P - 2, P);
        }
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            m = sc.nextInt();
            long res = C(n + m - 1, m - 1);
            out.println(res);
        }
        out.flush();
    }

    static long C(int n, int m) {
        return up[n] * inv[m] % P * inv[n - m] % P;
    }

    static long qmi(long a, int k, int p) {
        long res = 1;
        while (k > 0) {
            if ((k & 1) == 1) res = res * a % p;
            a = a * a % p;
            k >>= 1;
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
